Page({
  data: {
    dish: {
      id: '',
      name: '回锅肉',
      price: '17.54',
      description: '精选五花肉+秘制香料，口感鲜嫩，香辣可口',
      image: '/pages/images/dish1.jpg',
      tags: ['招牌菜', '香辣', '下饭菜'],
      cookTime: '15-20分钟',
      taste: '香辣',
      portion: '1份'
    },
    quantity: 1,
    reviews: [
      {
        id: 1,
        reviewer: '张先生',
        rating: 5,
        content: '味道很好，肉质鲜嫩，香辣适中，很下饭！',
        time: '2024-01-15'
      },
      {
        id: 2,
        reviewer: '李女士',
        rating: 4,
        content: '分量足，味道不错，就是稍微有点辣',
        time: '2024-01-14'
      },
      {
        id: 3,
        reviewer: '王先生',
        rating: 5,
        content: '回锅肉很正宗，肥而不腻，推荐！',
        time: '2024-01-13'
      }
    ],
    recommendDishes: [
      {
        id: 2,
        name: '小炒肉',
        price: '15.80',
        image: '/pages/images/dish2.jpg'
      },
      {
        id: 3,
        name: '炝炒莲白',
        price: '12.50',
        image: '/pages/images/dish3.jpg'
      },
      {
        id: 4,
        name: '麻婆豆腐',
        price: '13.80',
        image: '/pages/images/dish4.jpg'
      }
    ]
  },

  onLoad(options) {
    if (options && options.id) {
      this.setData({
        'dish.id': options.id
      })
    }
  },

  // 减少数量
  decreaseQuantity() {
    if (this.data.quantity > 1) {
      this.setData({
        quantity: this.data.quantity - 1
      })
    }
  },

  // 增加数量
  increaseQuantity() {
    this.setData({
      quantity: this.data.quantity + 1
    })
  },

  // 添加到购物车
  addToCart() {
    wx.showToast({
      title: '已添加到购物车',
      icon: 'success'
    })
  },

  // 立即下单
  orderNow() {
    wx.showToast({
      title: '功能开发中',
      icon: 'none'
    })
  },

  // 导航到其他菜品详情
  navigateToDish(e) {
    const dish = e.currentTarget.dataset.dish
    if (dish && dish.id) {
      wx.navigateTo({
        url: `/pages/dish-detail/dish-detail?id=${dish.id}`
      })
    }
  },

  // 分享给朋友
  onShareAppMessage() {
    return {
      title: '农家小炒 - 回锅肉',
      path: '/pages/dish-detail/dish-detail?id=1',
      imageUrl: '/pages/images/share.jpg'
    }
  },

  // 分享到朋友圈
  onShareTimeline() {
    return {
      title: '农家小炒 - 回锅肉',
      imageUrl: '/pages/images/share.jpg'
    }
  }
}) 